
#include <assert.h>

#include "User.h"

namespace TC
{
    namespace Data
    {
        User* User::_instance = nullptr;

        User::User()
        {
            assert(_instance == nullptr);

            _instance = this;
        }

        User::~User()
        {
            _instance = nullptr;
        }

        TC::Data::User* User::instance()
        {
            if (_instance == nullptr)
                _instance = new User;
            return _instance;
        }

        void User::setSignature(const QByteArray &data)
        {
            auto orgIsLogged = isLogged();
            if (&_signature != &data && _signature != data)
            {
                _signature = data;
                signatureChanged();

                if (orgIsLogged != isLogged())
                {
                    isLoggedChanged();
                }
            }
        }
    }
}